
use App\Http\Controllers\Controller;
use {{$fullClass}};

class {{$class}}Controller extends Controller
{
    public function create(){
        ${{$varName}} = new {{$class}}();
        ${{$varName}}->uid = auth()->id();
{% foreach ($createColumns as $column){ %}
        ${{$varName}}->{{$column}} = request('{{$column}}');
{% } %}
        ${{$varName}}->save();
        return $this->response(${{$varName}} );
    }
        public function update($id){
        /**
        * @var {{$class}} ${{$varName}}
        */
        ${{$varName}} = {{$class}}::whereUid(auth()->id())->findOrFail($id);
{% foreach ($updateColumns as $column){ %}
        if(!empty(request('{{$column}}'))){
            ${{$varName}}->{{$column}} = request('{{$column}}');
        }
{% } %}
        ${{$varName}}->save();
        return $this->response(${{$varName}});
    }

    public function list(){
        $model = {{$class}}::query();
        $model->where('uid',auth()->id());
{% foreach ($selectColumns as $column){ %}
        if(!empty(request('{{$column}}'))){
            $model->where('{{$column}}',request('{{$column}}'));
        }
{% } %}
        return $this->response($model->get());
    }

    public function find($id){
        $rs = {{$class}}::whereUid(auth()->id())->find($id);
        return $this->response($rs);
    }
    public function delete($id){
        $rs = {{$class}}::whereUid(auth()->id())->whereId($id)->delete();
        return $this->response($rs);
    }
}

Route::group(['prefix' => '{{$routeName}}'], function () {
    Route::post('','{{$class}}Controller@create');
    Route::post('/{id}','{{$class}}Controller@update');
    Route::get('','{{$class}}Controller@list');
    Route::get('/{id}','{{$class}}Controller@find');
    Route::delete('/{id}','{{$class}}Controller@delete');
});